﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Circle.Domain.Entity;
using Circle.Domain.Interface.UnitOfWork;
using Circle.Domain.Interface.Service;
using System.Web.Mvc;
using System.IO;
using System.Web.Optimization;

namespace Circle.Web
{
    public static class WebSiteConfig
    {
       
        private static string _layoutFileLocation;

        public static string LayoutFileLocation
        {
            get { return _layoutFileLocation; }
        }

        public static void Load()
        {
            LoadLayout();
        }

        private static void LoadLayout()
        {
            string layoutDirectory = HttpContext.Current.Server.MapPath(string.Format("/Themes/{0}/layout", WebCircleConfig.DefaultSetting.Theme));
            DirectoryInfo directoryInfo = new DirectoryInfo(layoutDirectory);
            var fileName = directoryInfo.GetFiles("*.cshtml").FirstOrDefault();
            if (fileName != null)
            {
                _layoutFileLocation = string.Format("~/Themes/{0}/layout/{1}", WebCircleConfig.DefaultSetting.Theme, fileName);
            }
        }

        public static List<string> GetThemes()
        {
            string themeDirectory = HttpContext.Current.Server.MapPath("/Themes");
            DirectoryInfo directoryInfo = new DirectoryInfo(themeDirectory);
            var topSubDirectories = directoryInfo.GetDirectories().Select(d => d.Name);
            return topSubDirectories.ToList();
        }

        public static List<string> GetSkins(string theme)
        {
            string skinDirectory = HttpContext.Current.Server.MapPath(string.Format("/Themes/{0}/skin", theme));
            DirectoryInfo directoryInfo = new DirectoryInfo(skinDirectory);
            var topSubDirectories = directoryInfo.GetDirectories().Select(d => d.Name);
            return topSubDirectories.ToList();
        }

    }
}